package com.iamk.finalthesis;

import java.util.ArrayList;
import java.util.HashMap;

public class Experiments {
	public static double unionArray(ArrayList<String> list1, ArrayList<String> list2) {
		int count = 0;
		for (int i = 0; i < list1.size(); i++) {
			if (list2.contains(list1.get(i))) {
				count++;
			}
		}
		return count;
	}
	public static double[] Micro_P(HashMap<String, ArrayList<String>> hash1,HashMap<String, ArrayList<String>> hash2){
		double[] result=new double[hash1.size()];
		ArrayList<String> temp1;
		ArrayList<String> temp2;
		for(int i=0;i<Constants._KEY;i++){
			temp1=hash1.get(Integer.toString(i+1));
			temp2=hash2.get(Integer.toString(i+1));
//			System.out.println("Size "+temp2.size());
			result[i]=unionArray(temp1, temp2)/(double)temp2.size();
		}
		return result;
	}
	public static void main(String[] args) {
		long start=System.currentTimeMillis();
		double count=0;
		HashMap<String, ArrayList<String>> hash1=LabelGroundTruth.mapLabel();
		HashMap<String, ArrayList<String>> hash2=Test.test();
		double[] temp=Micro_P(hash1, hash2);
		for(int i=0;i<temp.length;i++){
//			System.out.println((i+1)+" "+temp[i]);
			System.out.println("Label "+(i+1)+": "+temp[i]);
			if(temp[i]>0){
				count+=temp[i];
			}
		}
		long end=System.currentTimeMillis();
		System.out.println("TB :"+count/temp.length);
		System.out.println("Time :"+(end-start)/1000);
	}
}
